/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2011.08.12                                          *
 *                                                                       *
 *************************************************************************/

//declaration header
#include "COMMON/attr/Attribute.h"

//COMMON headers
#include "COMMON/info/InfoManager.h"
#include "COMMON/info/CommonInfo.h"
#include "COMMON/tbox/Utilities.h"
#include "COMMON/tbox/LogMessage.h"

#include <iostream>


namespace FreeMAPs
{

Attribute::Attribute (
    const std::string& parent_name,
    const std::string& attr_name):
    Parent (parent_name, attr_name, false),
    d_attr_name (attr_name),
    d_attr_db_file_name("Al.mat")
{}



Attribute::~Attribute()
{
    this->clear();
}



void
Attribute::clear()
{
}



void
Attribute::get_from_input (
    const InputDatabase* db)
{
    this->prepare_for_use (db);

    db->insert_allowable_key ("attr_db_file_name");

    db->check_allowable_keys ();

    /*
     * build attr_db_file_name
     */
    {
        if(db->key_exists("attr_db_file_name") && db->is_string("attr_db_file_name"))
        {
            db->check_requisite_key ("attr_db_file_name", DataType::STRING, false, false);
            d_attr_db_file_name = db->get_string ("attr_db_file_name");
            //std::cout << __FILE__ << __LINE__ << " d_attr_db_file_name = " << d_attr_db_file_name << std::endl;
        }

    }

}



std::ostream&
operator << (
    std::ostream& os,
    const Attribute& rhs)
{
    os << rhs.d_attr_name << "\n{\n";

    os << LogMessage::get_prefix (ONE_TAB) << "attr_db_file_name = \"" << rhs.get_attr_db_file_name() << "\"\n";

    os << "}";

    return os;
}

}
